package com.zhangxin.myblog.config;

import com.zhangxin.myblog.interceptor.LoginInterceptor;
import com.zhangxin.myblog.interceptor.MyInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author zhangxin
 * @date 2020/7/25
 */

//配置类
@Configuration
public class WebConfig implements WebMvcConfigurer {


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/admin/**")
                .excludePathPatterns("/admin", "/", "/admin/login");

        registry.addInterceptor(new MyInterceptor()).addPathPatterns("/personal","/updatepassword");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/upload/image/**").addResourceLocations("file:/home/upload/image/");
    }
}
